package com.glsc.ngateway.common.base.repo.mysql.gateway.platform;

import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.OwnCloudSystemDirConfig;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author xuchang
 */
@Repository
public interface OwnCloudSystemDirConfigRepo extends JpaRepository<OwnCloudSystemDirConfig, Long> {

    List<OwnCloudSystemDirConfig> findAllByVersionTimeNull();
    @Transactional
    @Modifying
    @Query(value = "update t_gw_owncloud_system_dir_config " +
            "set version_time = :versionTime, " +
            "update_account = :updateAccount "+
            "where version_time is null " +
            "and deleted = 0 " +
            "", nativeQuery = true)
    void setVersionTime(@NotNull @Param("versionTime") String versionTime, @Param("updateAccount") String updateAccount);
}
